package com.db;

import java.net.UnknownHostException;

import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.Mongo;
import com.mongodb.MongoException;

public class MongoDb {
	private static MongoDb instance;

	private DB db;
	public DBCollection getDbc() {
		return dbc;
	}

	public void setDbc(DBCollection dbc) {
		this.dbc = dbc;
	}

	private DBCollection dbc;
	private Mongo m;
	public final static String UGRSDESC = "u_g_r_s_d_e_s_c_model";
	public final static String ASDESC = "a_s_d_e_s_c_model";
	public final static String MSGDESC = null;
	

	private MongoDb() {
		try {
			m = new Mongo("localhost", 27017);
			db = m.getDB("storage");
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (MongoException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public static MongoDb getInstance() {
		if (instance == null) {
			instance = new MongoDb();
		}
		return instance;
	}
	
	public void setDBCollection(String collectionName){
		this.dbc = db.getCollection(collectionName);
	}
	
	public void setDB(String DBName){
		this.db = m.getDB(DBName);
	}

	public DB getDb() {
		return this.db;
	}

}
